<?
function paging($table,$where,$post,&$total,&$start,$limit=30,$numpage=5)
{
	include_once(INCLUDES."buildlink.php");
	if($post["page"]=="") $post["page"]=1;
	if($where=="") $where="1=1";
	$start=($post["page"]-1)*$limit;
	$q = query("select * from $table where $where");
	$total=ceil(numrows($q)/$limit);
	$startlist=($post["page"]-(int)(($numpage-1)/2)<=0?1:$post["page"]-(int)(($numpage-1)/2));
	$endlist=($startlist+$numpage-1>$total?$total:$startlist+$numpage-1);
	if($startlist>1) $listpage[]=array("link" => buildlink($post["act"],$post,$startlist-1), "title" => "<<");
	
	for($i=$startlist; $i<=$endlist; $i++)
	{
		$listpage[]=array("link" => buildlink($post["act"],$post,$i), "title" => $i);
		
	}
	if($endlist<$total) $listpage[]=array("link" => buildlink($post["act"],$post,$endlist+1), "title" => ">>");
	return $listpage;
}
?>